<?php

Class m_news extends CI_Model {

    function get_all_news() {
        $this->db->order_by("idnews", "DESC");
        $query = $this->db->get("news");
        return $query;
    }

    function insert_news($data) {
        return $this->db->insert('news', $data);
    }

    function get_by_id($idnews) {
        $query = $this->db->get_where('news', array('idnews' => $idnews));
        return $query->row_array();
    }

    function update_news($data, $idnews) {
        $this->db->where('news.idnews', $idnews);
        return $this->db->update('news', $data);
    }

    function delete_news($idnews) {
        $this->db->where('news.idnews', $idnews);
        return $this->db->delete('news');
    }

}